import java.util.*;

public class Sort{
    public static void main(String[] args){
        System.out.print("Enter the Number of Terms: ");
        Scanner c = new Scanner(System.in);
        int n = c.nextInt();
        System.out.print("Enter the Elements: ");
        int[] a;
        a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = c.nextInt();
        }
        System.out.print("You Entered: ");
        int sm = a[0];
        for(int i = 0; i < n; i++){
            System.out.print(a[i] + " ");
        }
        for(int i = 0; i < n-1; i++){
            for(int j = 0; j < n-i-1; j++){
                if(a[j] > a[j+1]){
                    sm = a[j];
                    a[j] = a[j+1];
                    a[j+1] = sm;
                }
            }
        }
        System.out.print("\nSorted Array: ");
        for(int i = 0; i < n; i++){
            System.out.print(a[i] + " ");
        }
        System.out.println();
    }
}